package $1_3array;

public class MultiArray {

	public static void main(String[] args) {
		// 多维数组
		int[][] ns = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
		System.out.println(ns.length); // 3
		int[] arr0 = ns[0];
		System.out.println(arr0.length); // 4

		// 用二维数组表示的学生成绩:
		int[][] scores = { { 82, 90, 91 }, { 68, 72, 64 }, { 95, 91, 89 }, { 67, 52, 60 }, { 79, 81, 85 }, };
		double average = 0;
		
		double averageeveryone = 0.00;
		for(int[] score : scores) {
			int count = 0;
			averageeveryone = 0.0;
			for(int scor : score) {
				count += scor; 
			}
			System.out.println(count);
			System.out.println(score.length);
			averageeveryone = (double)count/(score.length);
			average += averageeveryone;
			System.out.println(averageeveryone);
			System.out.println(average);
		}
		average = (double)average/(scores.length);
		
		System.out.println(average);

        if (Math.abs(average - 77.733333) < 0.000001) {
            System.out.println("测试成功");
        } else {
            System.out.println("测试失败");
        }
		
	}

}
